package jlib.component.button
{
	
	import flash.events.Event;
	import jlib.component.button.IButton;
	import jlib.component.button.IButtonStrategy;
	
	internal final class DefaultStrategy implements IButtonStrategy
	{
		private var _isSelected:Boolean;
		private var button:IButton;
		public function DefaultStrategy(button:IButton): void
		{
			this.button = button;
		}
		
		public function click(e:Event=null): void
		{
			if(button.hasState(ButtonState.ROLLOVER)) rollOver(e);
		}
		
		public function up(e:Event=null):void
		{
			_isSelected = false;
			button.view(ButtonState.UP);
		}
		
		public function down(e:Event=null):void
		{
			_isSelected = true;
			button.view(ButtonState.DOWN);
		}
		
		public function rollOver(e:Event=null):void
		{
			button.view(ButtonState.ROLLOVER);
		}
		
		public function rollOut(e:Event=null):void
		{
			button.view(ButtonState.ROLLOUT);
		}
		
		public function outside(e:Event=null):void
		{
			if(e.target != button) up();
		}
		
		public function isSelected(): Boolean
		{
			return _isSelected;	
		}
	}//c
}